package com.fannuo.demo.Util.hadoop;

import lombok.Getter;
import org.apache.hadoop.conf.Configuration;

@Getter
public class HadoopConfig {
    public final static String DEFAULT_HOST = "127.0.0.1";
    public final static int DEFAULT_PORT = 9000;
    private Configuration configuration;
    public HadoopConfig() {
        configuration = new Configuration();
        init();
    }
    public HadoopConfig(String host,int port) {
        configuration = new Configuration();
        String uri = "hdfs://"+host+":"+port;
        configuration.set("fs.defaultFS",uri);
        init();
    }
    private void init() {
        configuration.set("dfs.client.use.datanode.hostname","true");
    }

    public void set(String key,String value) {
        configuration.set(key,value);
    }
    public String get(String key) {
        return configuration.get(key);
    }
}
